// Author : Ajeng Ritanita Nur Widiati - 091511036

package jtk.project4.fleet.field;

import jtk.project4.fleet.domain.PmHist;
import nl.coderight.jazz.form.FormLayout;
import nl.coderight.jazz.form.FormLayout.Resize;
import nl.coderight.jazz.form.control.GroupControl;
import nl.coderight.jazz.form.control.RadioControl;
import nl.coderight.jazz.form.field.ComboField;
import nl.coderight.jazz.form.field.SelectField;
import nl.coderight.jazz.form.field.TextField;
import nl.coderight.jazz.form.field.button.CheckButton;
import nl.coderight.jazz.form.field.button.MenuButton; 
import nl.coderight.jazz.form.field.button.RadioButton;

public class addMaintenanceTaskField extends GroupControl<PmHist>{
	private RadioControl maintTypeField; 
	private RadioButton preventive;
	private RadioButton repair;
	//private ComboField serviceField;
	private SelectField serviceField;
	private TextField partsCostField;
	private TextField laborCostField;
	private TextField totalField;
	private ComboField typeField;
	private CheckButton itemizeParts;
	private CheckButton itemizeLabor;
	private CheckButton underWarranty;
	
	public addMaintenanceTaskField(String bindID){
		setTitle("header.addMaintenanceTask");
		setBindID(bindID);
		createFields();
		createLayout();
	}
	
	private void createFields(){
		maintTypeField = new RadioControl<String>("maintType");
		preventive = new RadioButton("preventive");
		repair = new RadioButton("repair");
		maintTypeField.addRadioButton(preventive,"preventive");
		maintTypeField.addRadioButton(repair,"repair");
		
		serviceField = new SelectField<String>("AddMaintenanceTask","service");
		
		partsCostField = new TextField("pCost", 10);
		itemizeParts = new CheckButton("itemizeParts");
		
		laborCostField = new TextField("lCost", 10);
		itemizeLabor = new CheckButton("itemizeLabor");
		
		totalField = new TextField("cost", 10);
		underWarranty = new CheckButton("underWarranty");
		
		typeField = new ComboField<String>("AddMaintenanceTask","type");
		typeField.setPreferredSize(partsCostField.getPreferredSize());
	}
	
	private void createLayout() {
		setLayout(new FormLayout())
		.addLabel("label.maintType").addField(maintTypeField, Resize.HORIZONTAL)
		.addLabel("maintTypeField")
		.addField(maintTypeField)
		.addRow()
		.addLabel("label.service").addField(serviceField, Resize.HORIZONTAL)
		.addLabel("label.type").addField(typeField)
		.addRow()
		.addLabel("label.partsCost").addField(partsCostField)
		.addField(itemizeParts)
		.addRow()
		.addLabel("label.laborCost").addField(laborCostField)
		.addField(itemizeLabor)
		.addRow()
		.addLabel("label.total").addField(totalField)
		.addField(underWarranty)
		.addRow() 
		;
	}
	
}
